import vine from '@vinejs/vine'

export const createMemberSchema = vine.object({
  fkSourceId: vine.number().optional(),
  fkPostId: vine.number().optional(),
  type: vine.number().range([1, 2]),
  name: vine.string().maxLength(50),
  nickName: vine.string().maxLength(20),
  keywords: vine.string().maxLength(60),
  password: vine.string().maxLength(32),
  avatarUrl: vine.string().maxLength(300),
  sex: vine.number().range([0, 2]),
  age: vine.number().positive(),
  birthdayType: vine.number().range([0, 2]),
  birthday: vine
    .date({
      formats: 'YYYY-MM-DD',
    })
    .optional(),
  lunarBirthday: vine
    .date({
      formats: 'YYYY-MM-DD',
    })
    .optional(),

  phone: vine.string().mobile({ locale: ['zh-CN'] }),
  email: vine.string().email().optional(),
  openid: vine.string().maxLength(30).optional(),
  unionid: vine.string().maxLength(30).optional(),
  status: vine.number().range([0, 1]).optional(),
  memo: vine.string().maxLength(255).optional(),
})

export const createMemberValidator = vine.compile(createMemberSchema)

export const updateMemberValidator = vine.compile(createMemberSchema)
